<?php
// botão para inserir uma nova saida
if ($this->controllerACL->permissaoBotao("saida/novo")) {
    echo "<a href='" . BASE_URL . "saida/novo'><input type='button' id='salvar-tsaida' value='Nova Saída' class='mws-button green right margin-10px'/></a>";
}
?>

<?php
if (!isset($data["ano"])) {
    $ano = date('Y');
    $mes = date('m');
}
?>

<div class="mws-panel grid_8">

    <div class="mws-panel-header">
        <span class="mws-i-24 i-table-1">Saídas</span>

        <select id="ano" class="input-small right select-grid" name="ano">
            <?php
            foreach ($data[1] as $anoL) {
                echo "<option value='" . $anoL . "'";

                if ($anoL == $ano) {
                    echo " SELECTED";
                }

                echo ">" . $anoL . "</option>";
            }
            ?>
        </select>    
        <select id="mes" class="input-small right select-grid" name="mes">
            <?php
            foreach ($data[0] as $mesL) {
                echo "<option value='" . $mesL->codigo . "'";

                if ($mesL->codigo == $mes) {
                    echo " SELECTED";
                }

                echo ">" . $mesL->mes . "</option>";
            }
            ?>
        </select>
    </div>
    <div class="mws-panel-body" id="saida">

    </div>
</div>

<script type="text/javascript">
    $("#saida").load("<?php echo BASE_URL; ?>saida/lista", function() {
        __dataTable();
    });

    $(".select-grid").on("change", function() {
        loadSaidas();
    });

    function loadSaidas() {
        $("#saida").load("<?php echo BASE_URL; ?>saida/lista", {mes: $('#mes').val(), ano: $('#ano').val()}, function() {
            __dataTable();
            addNotify("sucesso");
        });
    }
</script>